
var cardInfo =$("#cardIdInfo");
var cardId = $("#cardId");

$(document).ready(function(){
    cardId.blur(validateCardId);

} );

function validateCardId(){
     var val = document.getElementById("cardId").value;
     if(val.length<3 ) {
          cardInfo.addClass('errorField');
          cardInfo.text("ID must be more than 3 munbers") ;
     }else if(val.match(/^\d+(?:\.\d+)?$/)){
            cardInfo.removeClass('errorField');
            cardInfo.text("" ) ;
            return true;
            }else{
            cardInfo.addClass('errorField');
            cardInfo.text("Invalid Card ID: "+ val) ;
            return false;
         }
}
function load(){
    if(validateCardId()){
        var params =  "cardId="+document.getElementById("cardId").value;
        ajaxPost("?tld/getCardInfo", params, function(data) {
                   var response =JSON.parse(data);
                   if (response.status==false) {
                       return;
                   }
                    $("#cardInfo").html("" ) ;
                    $("#cardInfo").html(response.tableHtml) ;
                    $("#messagePanel").removeClass();
                    $("#messagePanel").html("" ) ;

               });

    }
}




